home *** CD-ROM | disk | FTP | other *** search
- Path: ns.etri.re.kr!jinsoo
- From: jinsoo@etri.re.kr (Jin-Soo Lee)
- Newsgroups: comp.lang.c
- Subject: HELP: What is wrong ?
- Date: 16 Jan 1996 02:40:35 GMT
- Organization: Electronics and Telecommunications Research Inst. (ETRI)
- Message-ID: <4df373$kd3@ns.etri.re.kr>
- Reply-To: jinsoo@dbserver.etri.re.kr
- NNTP-Posting-Host: musso.etri.re.kr
- X-Newsreader: TIN [version 1.2 PL2]
-
- Your KIND HELP is needed.
- I have some problems in the following code.
-
- ---------
-
- #define DSKPAGESIZE 16*1024
- #define LOGBUFSIZE 2*DSKPAGESIZE
-
- main()
- {
- int pageBS, logoffset, bufferoffset, buffersize, length;
- int freespace, inusefile;
- char *globla_page;
- T_LOGRECORD *tlogrec;
- ....
- (1) pageBS = (logoffset/LOGBUFSIZE) * LOGBUFSIZE;
- ....
- (2) bufferoffset = (logoffset + length)%LOGBUFSIZE;
- ....
- (3) tlogrec = (T_LOGRECORD *)(global_page + (logoffset%LOGBUFSIZE));
- ....
- freespace = inuselogfile - logoffset;
- (4) if (freespace - length > sizeof(int))
- ....
- freespace = buffersize - bufferoffset;
- (5) if (freespace - length >= sizeof(int))
- ....
- }
-
- ---------
-
- The code worked well on SUN OS 4.1.3. and K&R C with dbx,
- but goes wrong when moved to current environment,
- Solaris 2.4 and SUN C with SparcWorks dbx and gcc with gdb.
- The statements (1) ~ (5) sometimes make too big or negative values.
- I can't believe it.
- What happened ?
- OS or compiler problem ? or C language syntax problem ?
-
- Any help is greatly appreciated. Please e-mail me.
-
- --
- Jin-Soo Lee Internet: jinsoo@dbserver.etri.re.kr
- DB Section, Electronics and Telecommunications Research Inst. (ETRI)
- P.O. Box 106, You-Seong, Taejon, 305-600, Korea
- TEL: +82-42-860-4865 FAX: +82-42-860-6645
-